home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / src / WBBump_src.lha / WBBump_src / ScreenNotify.e < prev    next >
Encoding:
Text File  |  1999-06-30  |  3.7 KB  |  162 lines

  1. /* ************** */
  2. /* ScreenNotify.e */
  3. /* ************** */
  4.  
  5.  
  6.  
  7. /*
  8.     WBBump - Bumpmapping on the Workbench!
  9.  
  10.     Copyright (C) 1999  Thomas Jensen - dm98411@edb.tietgen.dk
  11.  
  12.     This program is free software; you can redistribute it and/or modify
  13.     it under the terms of the GNU General Public License as published by
  14.     the Free Software Foundation; either version 2 of the License, or
  15.     (at your option) any later version.
  16.  
  17.     This program is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.     GNU General Public License for more details.
  21.  
  22.     You should have received a copy of the GNU General Public License
  23.     along with this program; if not, write to the Free Software Foundation,
  24.     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25. */
  26.  
  27.  
  28. /*
  29.     about this module:
  30.     the calls to screennotify.library are made in inline assembler.
  31.     This is because there's no screennotify modules in std. E package
  32. */
  33.  
  34.  
  35.  
  36. OPT MODULE
  37.  
  38. OPT PREPROCESS
  39.  
  40.  
  41.  
  42. MODULE    'intuition/screens',
  43.  
  44.         'exec/ports',
  45.  
  46.         'amigalib/ports'
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. DEF screennotifybase
  54.  
  55.  
  56.  
  57. #define SCREENNOTIFY_TYPE_CLOSESCREEN   0 /* CloseScreen() called, snm_Value contains */
  58.                                           /* pointer to Screen structure              */
  59. #define SCREENNOTIFY_TYPE_PUBLICSCREEN  1 /* PubScreenStatus() called to make screen  */
  60.                                           /* public, snm_Value contains pointer to    */
  61.                                           /* PubScreenNode structure                  */
  62. #define SCREENNOTIFY_TYPE_PRIVATESCREEN 2 /* PubScreenStatus() called to make screen  */
  63.                                           /* private, snm_Value contains pointer to   */
  64.                                           /* PubScreenNode structure                  */
  65. #define SCREENNOTIFY_TYPE_WORKBENCH     3 /* snm_Value == FALSE (0): CloseWorkBench() */
  66.                                           /* called, please close windows on WB       */
  67.                                           /* snm_Value == TRUE  (1): OpenWorkBench()  */
  68.                                           /* called, windows can be opened again      */
  69.  
  70.  
  71.  
  72. OBJECT screennotifymessage
  73.     msg        :    mn
  74.     type    :    LONG
  75.     value    :    LONG
  76. ENDOBJECT
  77.  
  78.  
  79.  
  80.  
  81. OBJECT screennotify
  82. PRIVATE
  83.     s        :    PTR TO screen
  84.     mp        :    PTR TO mp
  85.     handle    :    LONG
  86. ENDOBJECT
  87.  
  88.  
  89. PROC screennotify() OF screennotify
  90.     self.s := NIL
  91.     self.mp := NIL
  92. ENDPROC
  93.  
  94.  
  95. /* returns bool */
  96. PROC install(scrname) OF screennotify HANDLE
  97.     self.s := LockPubScreen(scrname)
  98.     IF self.s = NIL THEN Raise(-1)
  99.  
  100.     self.mp := createPort(NIL, 0)
  101.     IF self.mp = NIL THEN Raise(-1)
  102.  
  103.     self.handle := addCloseScreenClient(self.s, self.mp, 0)
  104.     IF self.handle = NIL THEN Raise(-1)
  105.  
  106. EXCEPT DO
  107.     IF self.s THEN UnlockPubScreen(NIL, self.s)
  108.     IF exception
  109.         self.remove()
  110.         RETURN FALSE
  111.     ENDIF
  112. ENDPROC TRUE
  113.  
  114.  
  115. PROC remove() OF screennotify
  116.     IF self.handle THEN remCloseScreenClient(self.handle)
  117.     self.handle := NIL
  118.     IF self.mp THEN deletePort(self.mp)
  119.     self.mp := NIL
  120.     self.s := NIL
  121. ENDPROC
  122.  
  123.  
  124. PROC end() OF screennotify
  125.     self.remove()
  126. ENDPROC
  127.  
  128.  
  129. /* returns bool */
  130. PROC closerequest() OF screennotify HANDLE
  131.     DEF    snm=NIL:PTR TO screennotifymessage,
  132.         close=FALSE
  133.  
  134.     IF self.mp
  135.         IF (snm := GetMsg(self.mp))
  136.             IF snm.type = SCREENNOTIFY_TYPE_CLOSESCREEN
  137.                 IF snm.value = self.s THEN close := TRUE
  138.             ENDIF
  139.         ENDIF
  140.     ENDIF
  141.  
  142. EXCEPT DO
  143.     IF snm THEN ReplyMsg(snm)
  144. ENDPROC close
  145.  
  146.  
  147. /* calls to screennotify */
  148. PROC addCloseScreenClient(screen, msgport, priority)
  149.     MOVE.L    screennotifybase,A6
  150.     MOVE.L    screen,A0
  151.     MOVE.L    msgport,A1
  152.     MOVE.L    priority,A2
  153.     JSR        -30(A0)
  154. ENDPROC
  155.  
  156. PROC remCloseScreenClient(handle)
  157.     MOVE.L    screennotifybase,A6
  158.     MOVE.L    handle,A0
  159.     JSR        -36(A0)
  160. ENDPROC
  161.  
  162.